package algorithmTopics.string;

public class test5 {

    public static void main(String[] args) {
        test5 test2 = new test5();
        test2.isPalindrome("OP");
    }
    public boolean isPalindrome(String s) {
        s = s.toLowerCase();
        for (int i = 0 ,j = s.length() - 1; i < j;i++,j--) {
            while (!Character.isLetterOrDigit(s.charAt(i))) {
                if (i == j) {
                    break;
                }
                i++;
            }
            while (!Character.isLetterOrDigit(s.charAt(j))) {
                if (i == j) {
                    break;
                }
                j--;
            }
            if (s.charAt(i) != s.charAt(j)) {
                return false;
            }
        }

        return true;
    }


}
